﻿@{
    Layout = null;
}
@using ZBJF.Warranty.Common.Enums
@using ZBJF.Warranty.WebProvider.AdminPemission
@using EnumHelper = ZBJF.Warranty.Common.Common.EnumHelper
@model List<ZBJF.Warranty.Model.PageMenu>
@foreach (var item in Model.Where(m => m.ParentID == ViewBag.Pid))
{
    int layer = ViewBag.Layer;
    var paddingLeft = 30 * layer + "px";
    <tr layer="@layer">
        <td class="category">
            <span class="close" attr-id="close" style="margin-left: @paddingLeft" onclick="categoryTree(this, @layer)"></span>
            @item.PageName
        </td>
        <td>@(EnumHelper.Instance.GetDescription(typeof(ApplicationType), item.BelongApplicationType))</td>
        <td><i class="@item.IcoClass bigger-120"></i>@item.IcoClass</td>
        <td>@item.PageUrl</td>
        <td>
            @{
    var actions = RightHelper.Instance.GetAllPageToAction().Where(p => p.PageID == item.ID).Select(a => a.PageAction.ActionName).ToList();
    if (actions.Any())
    {
        @actions.Aggregate(string.Empty, (c, d) => c + d + ",").Trim(',');
    }
            }
        </td>
        <td>
            @if (item.IsShow == true)
            {
                <i class="icon-ok green bigger-120"></i>
            }
            else
            {
                <i class="icon-remove red bigger-120"></i>
            }
        </td>
        <td>@item.OrderIndex</td>
        <td>
            <a href="javascript:showLayerOpen('编辑菜单', '/System/PageMenu/Edit/@item.ID', '500px', '60%')" class="Edit-R" title="编辑"><i class="icon-pencil green bigger-120"></i></a>
            <a href="javascript:UpdateAction('@item.ID')" class="Edit-R" title="设置菜单按钮"><i class="icon-user green bigger-120"></i></a>
            <a href="javascript:DeleteObj('@item.ID','/System/PageMenu/DeletePageMenu','')" class="Delete-R" title="删除"><i class="icon-trash red bigger-120"></i></a>
        </td>
    </tr>
            var childMenu = Model.Where(m => m.ParentID == item.ID).OrderBy(o => o.OrderIndex).ToList();
            layer = layer + 1;
            if (childMenu.Any())
            {
                @Html.Action("ShowMenuList", "PageMenu", new { listPage = Model, pid = item.ID, layer = layer })
            }
            layer = layer - 1;
}